package com.lysj.food.customer.controller;

import com.lysj.admin.utils.spring.foundation.base.BaseContent;
import com.lysj.admin.utils.validation.annotation.Valid;
import com.lysj.admin.utils.web.Resp;
import com.lysj.food.food.dto.FoodAndCount;
import com.lysj.food.food.dto.OrderAddDto;
import com.lysj.food.food.service.FoodService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Created by wtl on 2019-03-26 15:28:03
 * @description 小程序菜品控制层
 */
@Slf4j
@RestController
@RequestMapping("/food/management/customer")
public class CustomerFoodController extends BaseContent {

    @Resource
    private FoodService foodService;


    /**
     * @author Created by wtl on 2019/3/26 17:37
     * @Description 获取本店的菜品
     */
    @GetMapping("/find_store_food")
    public Resp findStoreFood(String storeId) {
        return new Resp().success(foodService.getStoreFoodList(storeId));
    }

    /**
     * @author Created by wtl on 2019/3/29 14:52
     * @Description 根据菜品类型获取菜品列表
     */
    @GetMapping("/find_food_by_type")
    public Resp findFoodByType(String foodTypeId) {
        return new Resp().success(foodService.findByFoodTypeId(foodTypeId));
    }

    /**
     * @author Created by wtl on 2019/4/1 15:12
     * @Description 点菜下单接口
     */
    @PostMapping("/create_order")
    public Resp createOrder(@Valid OrderAddDto orderAddDto) {
        return new Resp().success(foodService.createOrder(orderAddDto), "下单成功");
    }

    /**
     * @author Created by wtl on 2019/4/2 9:48
     * @Description 加菜接口
     */
    @PostMapping("/order_modify")
    public Resp orderModify(String orderId, String foodAndCounts) {
        return new Resp().success(foodService.orderModify(orderId, foodAndCounts), "加菜成功");
    }

    /**
     * @author Created by wtl on 2019/4/2 16:18
     * @Description 称重
     */
    @PostMapping("/order_item_modify")
    public Resp orderItemModify(String weighFoodId, String weight) {
        return new Resp().success(foodService.orderItemModify(weighFoodId, weight));
    }

}
